/*
 *     This file is part of Mobile GPS Logger.
 *
 *     Mobile GPS Logger is free software: you can redistribute it and/or
 *     modify it under the terms of the GNU General Public License as
 *     published by the Free Software Foundation, either version 3 of the
 *     License, or (at your option) any later version.
 *
 *     Mobile GPS Logger is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License v3 for more details.
 *
 *     You should have received a copy of the GNU General Public License v3
 *     along with Mobile GPS Logger. If not, see <http://www.gnu.org/licenses/>.
 */

package cx.ath.skyflyer.gpslog.ui;

import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.midlet.MIDlet;

/**
 *
 * @author Ahti Legonkov
 */
public class Alert {

    public Alert(MIDlet midlet) {
        this.m_Midlet = midlet;

        Display disp = Display.getDisplay(midlet);
        this.m_Current = disp.getCurrent();
    }

    public void display(String error, AlertType type) {
        display(error, type, m_Timeout);
    }

    public void display(String error, AlertType type, int timeout) {
        javax.microedition.lcdui.Alert alert = new javax.microedition.lcdui.Alert(
                m_Current.getTitle(), error, null, type);
        alert.setTimeout(timeout);
        Display.getDisplay(m_Midlet).setCurrent(alert, m_Current);
    }

    private MIDlet m_Midlet;
    private Displayable m_Current;
    private int m_Timeout = 2000;
}
